package com.chuangxin.data.core;

import com.chuangxin.data.core.io.DataOutput;

/**
 * Created by Dawnwords on 2015/2/1.
 */
public abstract class IDBasedFetcher extends URLContentIndependentFetcher {

    private int currentId;
    private int end;
    private String template;

    public IDBasedFetcher(DataOutput output, int start, int end, String template) {
        super(1, output);
        currentId = start;
        this.end = end;
        this.template = template;
    }

    @Override
    protected final String nextURL() {
        return template.replace("${id}", String.valueOf(currentId++));
    }

    @Override
    protected final boolean hasNextURL() {
        return currentId <= end;
    }

}
